import 'package:flutter_bilibili/dao/api_service.dart';
import 'package:flutter_bilibili/model/news_model.dart';
import 'package:get/get.dart';

import 'news_state.dart';

class NewsLogic extends GetxController {
  final NewsState state = NewsState();

  var isLoading = true.obs;

  // ignore: deprecated_member_use
  var newsList = <NewsModel>[].obs;

  @override
  void onInit() {
    // TODO: implement onInit
    fetchMovie();
    super.onInit();
  }

  void fetchMovie() async {
    try {
      isLoading(true);
      var movie = await ApiService.fetchMovie();
      if (movie != null) {
        newsList.assignAll(movie);
      }
    } finally {
      isLoading(false);
    }
  }
}
